import { shallow as vueShallow, mount as vueMount, createLocalVue } from 'vue-test-utils'
import Vuex from 'vuex'
import VueRouter from 'vue-router'
import 'element-ui/lib/theme-chalk/index.css'
import requestForm from '@/store/modules/requestForm'
import 'common/css/base.scss'

import {
  Loading,
  MessageBox,
  Message
} from 'element-ui'

const localVue = createLocalVue()

const router = new VueRouter()
localVue.use(Loading)
localVue.use(MessageBox)
localVue.use(Message)
localVue.use(Vuex)
localVue.use(VueRouter)

let store = new Vuex.Store({})
store.registerModule('requestForm', requestForm)

const shallow = (Component, {propsData = {}, stubs = []} = {}) => {
  const wrapper = vueShallow(Component, {
    propsData,
    store,
    localVue,
    router
  })

  return wrapper
}

const mount = (Component, {propsData = {}, stubs = []} = {}) => {
  const wrapper = vueMount(Component, {
    propsData,
    store,
    localVue,
    router
    // attachToDocument: true
  })

  return wrapper
}

export { mount, shallow }
